package main

import (
	"fmt"
	"github.com/boltdb/bolt"
	"log"
)

func main() {
	// Open the my.db data file in your current directory.
	// It will be created if it doesn't exist.
	// 1. 创建或者打开数据库
	db, err := bolt.Open("my.db", 0600, nil)
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	//2.创建表
	err = db.View(func(tx *bolt.Tx) error {

		//查询blockBucket表
		b := tx.Bucket([]byte("BlockBucket"))

		// 往表里面存储数据
		if b != nil {
			data := b.Get([]byte("l"))
			fmt.Println(string(data))
			data = b.Get([]byte("ll"))
			fmt.Println(string(data))
		}

		return nil
	})

	if err != nil {
		log.Panic(err)
	}

}
